package com.kj.platformlogistics.home.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kj.platformlogistics.R;
import com.kj.platformlogistics.home.model.PersonSelectListModel;
import com.kj.platformlogistics.home.model.StockListModel;

import java.util.List;

public class PersonSelectListAdapter extends BaseQuickAdapter<PersonSelectListModel.ResultDTO, BaseViewHolder> {

    public PersonSelectListAdapter(@Nullable List<PersonSelectListModel.ResultDTO> data) {
        super(R.layout.item_person_selecte, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PersonSelectListModel.ResultDTO item) {
        ImageView ivSelected=helper.getView(R.id.ivSelected);
        helper.setText(R.id.tvUserName,item.getName());
        helper.setText(R.id.tvUserPhone,item.getPhone());

        if (item.getSelected()==null){
            item.setSelected(false);
        }

            ivSelected.setVisibility(View.VISIBLE);
            if (item.getSelected()){
                ivSelected.setImageResource(R.mipmap.icon_selected_dot);
            }else {
                ivSelected.setImageResource(R.mipmap.icon_unselected_dot);
            }

        helper.addOnClickListener(R.id.ivSelected);
    }
}
